#!python
# -*- encoding: utf-8 -*- 
import re, urllib.parse, urllib.request
def iriToUri(iri):
    parts= urllib.parse.urlparse(iri)
    cc = []
    for parti, part in enumerate(parts):
        if len(part) > 0:
            part = urllib.parse.quote(part)
        cc += [part]
    return urllib.parse.urlunparse(cc)
